package com.xiaochong.tir.api.filter;

import com.xc.logclient.utils.LogTrace;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * Created by Administrator on 2018/6/12.
 */
@Aspect
@Component
public class AopFilter {

    /**
     * 异步方法开启和关闭 LogTrace
     */
    @Pointcut("@annotation(org.springframework.scheduling.annotation.Async)")
    public void annotationPointCut() {}

    @Around("annotationPointCut()")
    public Object after(ProceedingJoinPoint joinPoint) throws Throwable {
        LogTrace.beginTrace();
        Object o = joinPoint.proceed();
        LogTrace.endTrace();
        return o;
    }
}
